<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>创建相册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta name="description" content=""/>
    <meta name="author" content=""/>


    <!-- Jquery -->
    <script th:src="@{/plugins/jquery/jquery-2.1.1.js}"></script>
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" th:href="@{/plugins/bootstrap/bootstrap.min.css}">
    <!-- Bootstrap -->
    <script th:src="@{/plugins/bootstrap/bootstrap.min.js}"></script>
    <!-- index -->
    <link th:href="@{/module/index/index.min.css}" rel="stylesheet" />
    <!-- layer  -->
    <script th:src="@{/plugins/layer/layer.js}"></script>

</head>

<body class="overflow-hidden">
<div class="padding-md">
    <form class="form-horizontal">
        <div class="form-group"><label for="photoAlbumName" class="col-sm-2 control-label">相册名称</label>
            <div class="col-sm-10"><input id="photoAlbumName" type="text" class="form-control"></div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group"><label class="col-sm-2 control-label" for="photoAlbumContent">相册简介</label>
            <div class="col-sm-10"><input id="photoAlbumContent" type="text" class="form-control"></div>
        </div>
        <div class="form-group">
            <button type="button" id="create" class="btn btn-block btn-outline btn-primary"
                    style="color:#1ab394;background-color:transparent;border-color:#1ab394;">创建</button>
        </div>
    </form>
</div>

<script th:inline="javascript">
    /*<![CDATA[*/
    $(function () {
        sysBingFunc();
        bingFunc();
    });
    function coloseWindow(){
        //当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }
    function bingFunc() {

        $("#create").click(function () {
            var photoAlbumName = $("#photoAlbumName").val();
            if (photoAlbumName == null || photoAlbumName == "") {
                layer.msg('相册名字不能为空！', {icon: 0});
                return;
            }
            var photoAlbumContent = $("#photoAlbumContent").val();
            if (photoAlbumContent == null || photoAlbumContent == "") {
                layer.msg('相册简介不能为空！', {icon: 0});
                return;
            }
            $.ajax({
                url: "/photo/addPhotoAlbum",
                dataType: "json",
                type: "post",
                data: {"name": photoAlbumName, "content": photoAlbumContent},
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg("相册创建成功！！！", {icon: 1});
                        setTimeout('coloseWindow()', '1000')
                    }
                }
            });
        });
    }

    function sysBingFunc() {

    }

    /*]]>*/
</script>
</body>
</html>
